package com.tcy.game.angryrobots;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.tcy.game.angryrobots.general.CommonUtils;
import com.tcy.game.angryrobots.ui.MainMenuScreen;
import com.tcy.game.angryrobots.ui.ScoresScreen;
import com.tcy.game.angryrobots.ui.WorldPresenter;

public class AngryRobotsGame extends Game implements AchievementsListener {

    Screen mainMenuScreen;
    Screen playingScreen;
    ScoresScreen scoresScreen;
    IShowScores showScores;
    ISubmitScores submitScores;
    AchievementsListener achievementsListener;

    @Override
    public void create() {

        CommonUtils.log("type: " + Gdx.app.getType());
        Assets.load();
        mainMenuScreen = new MainMenuScreen(this);
//        playingScreen = new WorldPresenter(this);
//        scoresScreen = new ScoresScreen(this);
        setScreen(mainMenuScreen);
    }

    @Override
    public void onAttained(StatusManager.Achievements achievement) {
        if (achievementsListener != null) {
            achievementsListener.onAttained(achievement);
        }
    }

    public boolean canShowScores() {
        return showScores != null;
    }


    public void submitScore(int score) {
        if (submitScores != null) {
            submitScores.submitScore(score);
        }
    }

    public void showScores() {
        if (showScores != null) {
            showScores.showScores();
        }
    }

    public void setShowScores(IShowScores showScores) {
        this.showScores = showScores;
    }

    public void setSubmitScores(ISubmitScores submitScores) {
        this.submitScores = submitScores;
    }

    public void setAchievementsListener(AchievementsListener listener) {
        this.achievementsListener = listener;
    }

    @Override
    public void resize(int width, int height) {
        mainMenuScreen.resize(width, height);
        super.resize(width, height);
    }
}
